<?php
class newsAction extends Ac {
	
	public $isAdmin=false;
	public $login_expire = 3600;
	public function __construct(){
		parent::__construct();
	}
	
    public function lists(){
		$this->model = "News";
		$M = M($this->model);		
		$MCount = clone $M;
		$MyPage = MyPage($MCount->count(), 10);
		$M->limit($MyPage['firstRow'] . ',' . $MyPage['listRows']);
		$M->field('*');
		$M->order('id desc');
		$list = $M->select();					
        $this->assign("page", $MyPage['page']);
        $this->assign("lists", $list); //数据循环变量
		$this->assign('empty','<tr><td colspan="3" align="center">没有找到数据</td></tr>');
		$this->assign('tabs',"文章管理");//功能名称
		$this->display("default:template/news/lists");
    }
	
	public function edit(){
		$this->model = "News";
		$this->assign('act',"add");//操作方法
		$this->assign('tabs',"新增文章");//功能名称
		$navi = $this->navigation(11);
		if($_GET['act']=="edit"){
			$this->assign('act',"edit");//操作方法	
			$res = M($this->model)->where('id='.$_GET['id'])->find();
			$this->assign('tabs',"修改文章");//功能名称
			$navi = $this->navigation(12);
		}
		$this->res = $res;
		$this->navig = $navi['nav']; 
		$this->lasturl = $navi['lasturl'];
		$this->callback = $this->lasturl;//回调地址
		$this->display("default:template/news/edit");
	}
	
	//设置导航
	public function getNav(){
	   $nav[1] = array(
	   			  "name"=>"文章管理",
				  "url"=>"/News/lists/",
	          );		    		  		  			  			  
	   $nav[11] = array(
	   			  "name"=>"新增文章",
	   		  );
	   $nav[12] = array(
	   			  "name"=>"修改文章",
	   		  );
			  	  		  			  		  
	   return $nav;		  			  			  		  	  		
   }	

	
}